In [1]:
    
#matplotlib inline
import numpy as np
import pandas as pd
import scipy.io as spio
import matplotlib.pyplot as plt
    
In [5]:
    
mat = spio.loadmat("/Volumes/Raw Data Backup/for imac/eyes/data_processing/data/bwsure1/bwsure1_proc.mat")
tg1 = mat['TG1']
tg2 = mat['TG2']
frames = mat['B'][mat['B'][:,-1] == 1]
    
In [6]:
    
frames
    
    Out[6]:
In [7]:
    
tg1
    
    Out[7]:
In [7]:
    
tg2
    
    Out[7]:
In [8]:
    
frame_df = pd.DataFrame({'time':frames[:,0], 'press num':np.r_[0:frames.shape[0]]})
    
In [10]:
    
rad_100_2_startframe = tg1[5,2] + 612  # why add 612 to start of rad_100_2?
rad_100_2_captures = frames[(frames[:,0] >= tg1[0,2]) & (frames[:,0] <= tg2[0,2])]
rad_100_2_captures = rad_100_2_captures[:,0]
rad_100_2_captures = rad_100_2_captures - rad_100_2_captures[0] # frame offsets
rad_100_2_frames = rad_100_2_startframe + rad_100_2_captures
    
In [11]:
    
offsets = np.array([i*33 for i in xrange(1,176)])  # why do we add 175 more frame times to the end of the captures?
    
My guess is that there are empirically 612 ms between RADIAL_TARGET_STARTED and when frames start being captured for every other radial target phase, and that there are 175 more frames saved to rad_100_2 than rad_100_1.
In [45]:
    
new_captures = frame_df[(frame_df['time'] >= tg1[0,2]) & (frame_df['time'] <= tg2[0,2])].copy()
new_captures -= new_captures.iloc[0]
new_captures['press num'] += 1 + frame_df['press num'].iloc[-1]
new_captures['time'] += rad_100_2_startframe
extra_buttons = [new_captures['press num'].iloc[-1] + i for i in xrange(1,176)]
extra_frame_times = [new_captures['time'].iloc[-1] + i*33 for i in xrange(1,176)]
extra_frames = pd.DataFrame({'time':extra_frame_times, 'press num': extra_buttons})
extra_frames = extra_frames[extra_frames['time'] < tg2[5,2]]
new_captures = pd.concat([new_captures, extra_frames])
new_captures
# extra_frames
    
    Out[45]:
In [44]:
    
more_frames = rad_100_2_frames[-1] + offsets
    
In [45]:
    
more_frames
    
    Out[45]:
In [62]:
    
rad_ind = 5
start = tg1[rad_ind,2]
end = tg2[rad_ind,2]
foi = frames[(frames[:,0] >= start) & (frames[:,0] <= end)]
foi[:,0] - start
    
    Out[62]:
In [63]:
    
# tkidrdp1
mat = spio.loadmat("/Volumes/Raw Data Backup/for imac/eyes/data_processing/data/tkidrdp1/tkidrdp1_proc.mat")
tg1 = mat['TG1']
tg2 = mat['TG2']
frames = mat['B'][mat['B'][:,-1] == 1]
    
In [64]:
    
tg1
    
    Out[64]:
In [65]:
    
tg2
    
    Out[65]:
In [66]:
    
frames
    
    Out[66]:
In [ ]:
    
rad_100_4_startframe = TG1[11,2] + 612;
rad_100_4_captures = frames(frames >= TG1[0,2] & frames <= TG2[0,2]);
rad_100_4_captures = rad_100_4_captures - rad_100_4_captures[0];
rad_100_4_frames = rad_100_4_startframe + rad_100_4_captures;
for j = 1:28
    rad_100_4_frames(end+1) = rad_100_4_frames(end) + 33;
end
    
In [67]:
    
3202 + 2*(28)
    
    Out[67]:
In [68]:
    
(3241 - 3203) / 2.
    
    Out[68]:
In [70]:
    
import yaml
    
In [77]:
    
q = yaml.load(open("/Users/bwsprague/GradSchool/Research/BerkeleyVisionStats/data/raw/gaze/tki/fixup.yaml", 'r'))
    
In [78]:
    
q
    
    Out[78]:
In [79]:
    
q[0]
    
    Out[79]:
In [ ]: